/*
 * This file contains security interface for the facade.
 * @author Group 10
 */
package rmiinterfaces;

import java.rmi.*;
import java.util.ArrayList;
import java.util.Map;
import rmiinterfaces.RequestTypes.RequestType;

// Interface to be implemented by Data Model to provide business layer service to forms 
// Can be called by Security Facade or individual forms. 
// See RequestTypes interface for description of the protocol. 
public interface SecurityInterface extends java.rmi.Remote {

// This is a serializable and typesafe version of boolean. 
public final class AuthReturn implements java.io.Serializable
{
    public static final AuthReturn TRUE = new AuthReturn(true);
    public static final AuthReturn FALSE = new AuthReturn(false);
    // private constructor, so that other constants are not created
    public boolean value;
    private AuthReturn(boolean val){this.value = val;}
    
    public boolean equals(Object o)
    {
        boolean retVal = false;
        
        AuthReturn other = (AuthReturn) o;
        
        retVal = (this.value == other.value);
        
        return retVal;
    }

} 
    // Execute a request reqNum with params plus authenticate with login and password
    // It is necessary to send login and password for every request
    //       because the protocol is stateless. 
    // Returns the result of the request. 
    Map<String,Object> execRequest(RequestType reqNum, Map<String, Object> params, String login, String psw) throws RemoteException;
    
    // A function for forms to login and verify the given password.
    // Also, it is needed for logging of users' logins.
    // Returns TRUE if authentication success, otherwise FALSE. 
    AuthReturn logIn(String login, String psw)  throws RemoteException;
    
    // A function for forms to logout.
    // Also, it is needed for logging of users' logouts.
    // Returns TRUE if logout success (i.e. login and password are correct), otherwise FALSE. 
    AuthReturn logOut(String login, String psw)  throws RemoteException; 
}
